<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<?php 
defined( '_VALID_MOS' ) or die( include_once("../../404.php") );

$sqlSes = "
SELECT `session`.`Ses_Id` , `session`.`Title`,`session`.`alias`
FROM `session`
WHERE `session`.`Frontpage` =1
ORDER BY `session`.`Order` DESC
LIMIT 0 , 10";

$cmdCat=$mysqli->prepare($sqlSes);
$cmdCat->execute() or die($mysqli->error);
$cmdCat->bind_result($SesID,$SesTitle,$Alias);
$cmdCat->store_result();

?>

<?php
    while($cmdCat->fetch())
    {
        echo '<div id="box_default">';
       	    echo '<div id="sub_box_default">';
        		echo '<div class="bg_tt_right"><div class="bg_tt_left"><div class="bg_tt"><div class="text_tt"><a href="./com_content/session/'.$Alias.'/kscdct.csp">'.$SesTitle.'</a></div> </div> </div> </div>';
        		echo '<div class="ct_right">';
        		echo '<div class="ct_left">';
        		echo '<div class="ct">';
                    $sqlNews = "SELECT `news`.`News_Id`, `news`.`Title`, `news`.`alias`, `news`.`Description`, `news`.`img_file`,
                		Date_Format(`news`.`Date`, '%d/%m/%Y - %h:%m') AS `date_add`,`news`.`img_status`, DateDiff( CurDate( ) , `news`.`Date` ) AS `Expires` , `category`.`alias` AS `AliasCat`
                		FROM `news` INNER JOIN `category` ON `category`.`Cat_Id` = `news`.`CatID` 
                        INNER JOIN `session` ON `session`.`Ses_Id` = `category`.`SesID`
                		WHERE `session`.`Ses_Id` = ? AND `news`.`Status` = 1
                		ORDER BY `news`.`Order` DESC
                        LIMIT 4 "; 
        
                    $cmdNews=$mysqli->prepare($sqlNews);      
                    $cmdNews->bind_param("s",$SesID);  
                    $cmdNews->bind_result($News_Id, $Title, $alias, $Description, $img_file,  $date_add, $img_status, $Expires,$AliasCat);
                    $cmdNews->execute() or die ($mysqli->error);
                    $cmdNews->store_result();
                    
                    if($cmdNews->num_rows>0){                           
                        if(($Alias=='khach-san')||($Alias=='hotel')){                               
                      		echo '<div class="col-A">';
                        		echo '<div >';
                            		$cmdNews->fetch() or die ($mysqli->error); // fetch dong dau tien
                                    if($row->img_file!='/pgd-omon/file_upload/image/no_image.jpg'){ 
                                        echo '<img style="margin-right: 10px" align="left" width="150" src="' .$img_file. '">'; 
                                    }
                        		echo '</div>';
                                echo '<div class="ttsk_title"><a href="./com_content/phong/'.$alias .'/csp.csp">'.$Title.'</a></div>';						
                        		echo '<div class="ttsk_description">'.$Description.'</div>';													
                    		echo '</div>';
                            
                      		echo '<div class="col-B">';
                        	echo '<ul>';
                       		while ($cmdNews->fetch()) {
                        		echo '<li><img src="templates/default/images/tip_icon.png">';             
                                echo '<a title="'.$Title.'" href="./com_content/article/'.$alias .'/csp.csp"">'.$Title.'</a>';
                                echo '</li>';
                       		};								
                       	    echo '</ul>';
                    		echo '</div>';                                                        
                        } else {                            
                      		echo '<div class="col-A">';
                        		echo '<div >';
                            		$cmdNews->fetch() or die ($mysqli->error); // fetch dong dau tien
                                    if($row->img_file!='/pgd-omon/file_upload/image/no_image.jpg'){ 
                                        echo '<img style="margin-right: 10px" align="left" width="150" src="' .$img_file. '">'; 
                                    }
                        		echo '</div>';
                                echo '<div class="ttsk_title"><a href="./com_content/article/'.$alias .'/csp.csp">'.$Title.'</a></div>';                                                                                            						
                        		echo '<div class="ttsk_description">'.$Description.'</div>';													
                    		echo '</div>';
                      
                      		echo '<div class="col-B">';
                        	echo '<ul>';
                       		while ($cmdNews->fetch()) {
                        		echo '<li><img src="templates/default/images/tip_icon.png">';             
                                echo '<a title="'.$Title.'" href="./com_content/article/'.$alias .'/csp.csp"">'.$Title.'</a>';
                                echo '</li>';
                       		};								
                       	    echo '</ul>';
                    		echo '</div>';
                        }
                    }
        		echo '</div>'; //end ct
        		echo '</div>'; //end left
        		echo '</div>'; //end right
        		echo '<div class="bg_bt_right"><div class="bg_bt_left"><div class="bg_bt"><div class="text_bt"></div></div></div></div>';
            echo '</div>'; //end sub_box_default
            echo '<div class="clear"></div>';
        echo '</div>'; // end box_default
    }
?>
